package com.byxy.shop.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import com.byxy.shop.service.MallIndexService;
import com.byxy.ssm.shop.vo.CarouselVO;
import com.byxy.ssm.shop.vo.CategoryVO;
import com.byxy.ssm.shop.vo.HotGoodsVO;
import com.byxy.ssm.shop.vo.NewGoodsVO;
import com.byxy.ssm.shop.vo.RecommendGoodsVO;

/**
 * @author 廖善椅
 * @ClassName MallController
 * @Description 控制类
 * @date 2020年5月8日
 */

@Controller
@RequestMapping("/")
public class MallController {
	
	@Autowired
	private MallIndexService mallIndexService;
	
	@GetMapping({"","index","/"})
	public String index(Model model) {
		List<CategoryVO> categories = mallIndexService.findCategoryVO();
		List<HotGoodsVO> hotGoodses = mallIndexService.findHotGoodsVO();
		List<NewGoodsVO> newGoodses = mallIndexService.findNewGoodsVO();
		List<RecommendGoodsVO> recommendGoodses = mallIndexService.findRecommendGoodsVO();
		List<CarouselVO> carousels = mallIndexService.findCarouselVO();

		model.addAttribute("categories", categories);
		model.addAttribute("hotGoodses", hotGoodses);
		model.addAttribute("newGoodses", newGoodses);
		model.addAttribute("recommendGoodses", recommendGoodses);
		model.addAttribute("carousels", carousels);
		return "mall/index";
	}
}
